import 'dart:convert' show json;

class TvLiveRsp {

  int errcode;
  String msg;
  String timestamp;
  List<TvLiveData> data;

  TvLiveRsp.fromParams({this.errcode, this.msg, this.timestamp, this.data});

  factory TvLiveRsp(jsonStr) => jsonStr == null ? null : jsonStr is String ? new TvLiveRsp.fromJson(json.decode(jsonStr)) : new TvLiveRsp.fromJson(jsonStr);

  TvLiveRsp.fromJson(jsonRes) {
    errcode = jsonRes['errcode'];
    msg = jsonRes['msg'];
    timestamp = jsonRes['timestamp'];
    data = jsonRes['data'] == null ? null : [];

    for (var dataItem in data == null ? [] : jsonRes['data']){
      data.add(dataItem == null ? null : new TvLiveData.fromJson(dataItem));
    }
  }

  @override
  String toString() {
    return '{"errcode": $errcode,"msg": ${msg != null?'${json.encode(msg)}':'null'},"timestamp": ${timestamp != null?'${json.encode(timestamp)}':'null'},"data": $data}';
  }
}

class TvLiveData {

  int deviceCapacity;
  int id;
  String chineseName;
  String englishName;
  String identifier;
  List<TvLiveChannels> channels;

  TvLiveData.fromParams({this.deviceCapacity, this.id, this.chineseName, this.englishName, this.identifier, this.channels});

  TvLiveData.fromJson(jsonRes) {
    deviceCapacity = jsonRes['deviceCapacity'];
    id = jsonRes['id'];
    chineseName = jsonRes['chineseName'];
    englishName = jsonRes['englishName'];
    identifier = jsonRes['identifier'];
    channels = jsonRes['channels'] == null ? null : [];

    for (var channelsItem in channels == null ? [] : jsonRes['channels']){
      channels.add(channelsItem == null ? null : new TvLiveChannels.fromJson(channelsItem));
    }
  }

  @override
  String toString() {
    return '{"deviceCapacity": $deviceCapacity,"id": $id,"chineseName": ${chineseName != null?'${json.encode(chineseName)}':'null'},"englishName": ${englishName != null?'${json.encode(englishName)}':'null'},"identifier": ${identifier != null?'${json.encode(identifier)}':'null'},"channels": $channels}';
  }
}

class TvLiveChannels {

  int adImgHeight;
  int adImgWidth;
  int channelId;
  int channelNum;
  int channelType;
  int chnType;
  int deviceCapacity;
  String adImg;
  String channelArea;
  String cornerImg;
  String englishName;
  String icon;
  String id;
  String name;
  String posterUrl;
  String streamsInvalidPicUrl;
  List<TvLiveStrean> streams;
  List<TvLiveTimeShift> timeshifts;

  TvLiveChannels.fromParams({this.adImgHeight, this.adImgWidth, this.channelId, this.channelNum, this.channelType, this.chnType, this.deviceCapacity, this.adImg, this.channelArea, this.cornerImg, this.englishName, this.icon, this.id, this.name, this.posterUrl, this.streamsInvalidPicUrl, this.streams, this.timeshifts});

  TvLiveChannels.fromJson(jsonRes) {
    adImgHeight = jsonRes['adImgHeight'];
    adImgWidth = jsonRes['adImgWidth'];
    channelId = jsonRes['channelId'];
    channelNum = jsonRes['channelNum'];
    channelType = jsonRes['channelType'];
    chnType = jsonRes['chnType'];
    deviceCapacity = jsonRes['deviceCapacity'];
    adImg = jsonRes['adImg'];
    channelArea = jsonRes['channelArea'];
    cornerImg = jsonRes['cornerImg'];
    englishName = jsonRes['englishName'];
    icon = jsonRes['icon'];
    id = jsonRes['id'];
    name = jsonRes['name'];
    posterUrl = jsonRes['posterUrl'];
    streamsInvalidPicUrl = jsonRes['streamsInvalidPicUrl'];
    streams = jsonRes['streams'] == null ? null : [];

    for (var streamsItem in streams == null ? [] : jsonRes['streams']){
      streams.add(streamsItem == null ? null : new TvLiveStrean.fromJson(streamsItem));
    }

    timeshifts = jsonRes['timeshifts'] == null ? null : [];

    for (var timeshiftsItem in timeshifts == null ? [] : jsonRes['timeshifts']){
      timeshifts.add(timeshiftsItem == null ? null : new TvLiveTimeShift.fromJson(timeshiftsItem));
    }
  }

  @override
  String toString() {
    return '{"adImgHeight": ${adImg != null?'${json.encode(adImg)}':'null'}Height,"adImgWidth": ${adImg != null?'${json.encode(adImg)}':'null'}Width,"channelId": $channelId,"channelNum": $channelNum,"channelType": $channelType,"chnType": $chnType,"deviceCapacity": $deviceCapacity,"adImg": ${adImg != null?'${json.encode(adImg)}':'null'},"channelArea": ${channelArea != null?'${json.encode(channelArea)}':'null'},"cornerImg": ${cornerImg != null?'${json.encode(cornerImg)}':'null'},"englishName": ${englishName != null?'${json.encode(englishName)}':'null'},"icon": ${icon != null?'${json.encode(icon)}':'null'},"id": ${id != null?'${json.encode(id)}':'null'},"name": ${name != null?'${json.encode(name)}':'null'},"posterUrl": ${posterUrl != null?'${json.encode(posterUrl)}':'null'},"streamsInvalidPicUrl": ${streamsInvalidPicUrl != null?'${json.encode(streamsInvalidPicUrl)}':'null'},"streams": $streams,"timeshifts": $timeshifts}';
  }
}

class TvLiveTimeShift {

  String url;

  TvLiveTimeShift.fromParams({this.url});

  TvLiveTimeShift.fromJson(jsonRes) {
    url = jsonRes['url'];
  }

  @override
  String toString() {
    return '{"url": ${url != null?'${json.encode(url)}':'null'}}';
  }
}

class TvLiveStrean {

  String definition;
  String optimizeUrl;
  String url;

  TvLiveStrean.fromParams({this.definition, this.optimizeUrl, this.url});

  TvLiveStrean.fromJson(jsonRes) {
    definition = jsonRes['definition'];
    optimizeUrl = jsonRes['optimizeUrl'];
    url = jsonRes['url'];
  }

  @override
  String toString() {
    return '{"definition": ${definition != null?'${json.encode(definition)}':'null'},"optimizeUrl": ${optimizeUrl != null?'${json.encode(optimizeUrl)}':'null'},"url": ${url != null?'${json.encode(url)}':'null'}}';
  }
}

